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!!!!!!!!!!!!!!/TM\\````````````]`0T#AI+!!!!!!!!!!!!!!!!!!!!"
		"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
		"!!!!V^@8````````````YO,C!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
		"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!(BY?`0T]````````"
		"````W^P<!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
		"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!0T]``@X^````````````[?HJ!!!!!!!!"
		"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
		"!!!!!!!!!!!!!!!!45V.`P\\_````````````^P<W&B97!!!!!!!!!!!!!!!!!!!!"
		"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
		"35F*`@X^`````````````@X^256&!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
		"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!-T-T`0T]````````"
		"````````LK[O!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
		"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!#QM,^@8V````````````````````1U.$"
		"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
		"!!!!!!!!!!!!!!!!!!!!FZ?8````````````````````\\_`P(2U>!!!!!!!!!!!!"
		"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
		"!!!!\"15&]`0T````````````````````[?HJ*#1E!!!!!!!!!!!!!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!!!!!!!!!!!!!!!!!!!!!"
		"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
		"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
		"";

Sleep::Sleep(): App() {
	// Keep the constructor empty and do most things in the init()
}
void Sleep::init() {
#ifdef Shutdown_DEBUG
	Serial.println(PSTR("Sleep::init()"));
#endif
	m_icon = new Icon(28,&Sleep_bitmap[0]);
}

void Sleep::setup() {
#ifdef Shutdown_DEBUG
	Serial.println(PSTR("Sleep::setup()"));
#endif
	Graphics.fillScreen(BLACK);
	Graphics.setRotation(3);
	m_button->draw();
}

void Sleep::close() {
#ifdef Shutdown_DEBUG
	Serial.println(PSTR("Sleep::close()"));
#endif
}

boolean Sleep::touch(Point p) {
	if (m_button->isClicked(p)) {
		m_button->flash();
		Hardware.shutdown();

		Appregistry.jumpToMenu();
		Appregistry.getCurrentApp()->setup();
		Appregistry.getCurrentApp()->display();
	}
	return true;
}
void Sleep::display() {
}

Sleep::~Sleep() {
}

App *sleep = new Sleep();


